{#**
 * 2007-2020 PrestaShop SA and Contributors
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <contact@prestashop.com>
 * @copyright 2007-2020 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 *#}

{% block order_preview %}
  <div class="row order-preview-content mt-2">
    <div class="col-5">
      <div class="row">
        <div class="col">
          <div class="row">
            <div class="col-1">
              <p class="mb-0">
                <i class="material-icons pr-1">local_shipping</i>
              </p>
            </div>
            <div class="col">
              <p class="mb-0">
                <strong>{{ 'Carrier'|trans({}, 'Admin.Global') }}:</strong>
                {% if not orderPreview.isVirtual %}
                  {{ orderPreview.shippingDetails.carrierName }}
                {% else %}
                  -
                {% endif %}
              </p>

              <p class="mb-0">
                <strong>{{ 'Tracking number'|trans({}, 'Admin.Shipping.Feature') }}:</strong>
                {% if not orderPreview.isVirtual and orderPreview.shippingDetails.trackingNumber is not empty %}
                  {{ orderPreview.shippingDetails.trackingNumber }}
                {% else %}
                  -
                {% endif %}
              </p>

              <p class="mb-2">
                <strong>{{ 'Shipping details'|trans({}, 'Admin.Orderscustomers.Feature') }}:</strong>
                {% if orderPreview.virtual %}
                  -
                {% endif %}
              </p>

              {% if not orderPreview.virtual %}
                <p class="mb-0">{{ orderPreview.shippingDetails.firstName }} {{ orderPreview.shippingDetails.lastName }}</p>
                {% if orderPreview.shippingDetails.company %}
                  <p class="mb-0">{{ orderPreview.shippingDetails.company }}</p>
                {% endif %}
                {% if orderPreview.shippingDetails.vatNumber %}
                  <p class="mb-0">{{ orderPreview.shippingDetails.vatNumber }}</p>
                {% endif %}
                <p class="mb-0">{{ orderPreview.shippingDetails.address1 }}</p>
                <p class="mb-0">{{ orderPreview.shippingDetails.address2 }}</p>
                <p class="mb-0">
                  {{ orderPreview.shippingDetails.city }},
                  {% if orderPreview.shippingDetails.stateName %}
                    {{ orderPreview.shippingDetails.stateName }}
                  {% endif %}
                  {{ orderPreview.shippingDetails.postalCode }}
                </p>
                <p class="mb-0">{{ orderPreview.shippingDetails.country }}</p>
                <p>{{ orderPreview.shippingDetails.phone }}</p>
              {% endif %}
            </div>
          </div>
        </div>
        <div class="col">
          <div class="row">
            <div class="col-1">
              <p class="mb-0">
                <i class="material-icons pr-1">receipt</i>
              </p>
            </div>
            <div class="col">
              <p class="mb-1">
                <strong>{{ 'Invoice details'|trans({}, 'Admin.Orderscustomers.Feature') }}:</strong>
              </p>

              <p class="mb-0">{{ orderPreview.invoiceDetails.firstName }} {{ orderPreview.invoiceDetails.lastName }}</p>
              {% if orderPreview.invoiceDetails.company %}
                <p class="mb-0">{{ orderPreview.invoiceDetails.company }}</p>
              {% endif %}
              {% if orderPreview.invoiceDetails.vatNumber %}
                <p class="mb-0">{{ orderPreview.invoiceDetails.vatNumber }}</p>
              {% endif %}
              <p class="mb-0">{{ orderPreview.invoiceDetails.address1 }}</p>
              <p class="mb-0">{{ orderPreview.invoiceDetails.address2 }}</p>
              <p class="mb-0">{{ orderPreview.invoiceDetails.country }}</p>
              <p class="mb-0">
                {{ orderPreview.invoiceDetails.city }},
                {% if orderPreview.invoiceDetails.stateName %}
                  {{ orderPreview.invoiceDetails.stateName }}
                {% endif %}
                {{ orderPreview.invoiceDetails.postalCode }}
              </p>
              <p class="mb-0">{{ orderPreview.invoiceDetails.phone }}</p>
              <p>{{ orderPreview.invoiceDetails.email }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="col-7">
      <div class="table-responsive">
        <table class="table product table-borderless border-bottom-0">
          <thead>
          <tr>
            {% if orderPreview.taxIncluded %}
              {% set taxInclusion = 'Tax included'|trans({}, 'Admin.Global') %}
            {% else %}
              {% set taxInclusion = 'Tax excluded'|trans({}, 'Admin.Global') %}
            {% endif %}

            <th>
              {{ 'Products'|trans({}, 'Admin.Global') }}
              ({{ orderPreview.productDetails|length }})
            </th>
            <th>{{ 'Reference'|trans({}, 'Admin.Global') }}</th>
            <th class="js-cell-product-stock-location">{{ 'Stock location'|trans({}, 'Admin.Orderscustomers.Feature') }}</th>
            {% if orderPreview.taxIncluded == false %}
              <th class="text-center">
                {{ 'Tax'|trans({}, 'Admin.Global') }}
              </th>
            {% endif %}
            <th class="text-center">{{ 'Quantity'|trans({}, 'Admin.Global') }}</th>
            <th class="text-center">
              {{ 'Total'|trans({}, 'Admin.Global') }}
              <small>{{ taxInclusion }}</small>
            </th>
          </tr>
          </thead>
          <tbody>
          {% for productDetail in orderPreview.productDetails %}
            <tr class="{% if loop.index > productsPreviewLimit %}js-product-preview-more d-none{% endif %}">
              <td class="p-1">{{ productDetail.name }}</td>
              <td class="p-1">{{ productDetail.reference }}</td>
              <td class="p-1 js-cell-product-stock-location">
                {% if productDetail.location is not empty %}{{ productDetail.location }}{% endif %}
              </td>
              {% if orderPreview.taxIncluded == false %}
                <td class="p-1 text-center">{{ productDetail.totalTax }}</td>
              {% endif %}
              <td class="p-1 text-center">{{ productDetail.quantity }}</td>
              <td class="p-1 text-center">{{ productDetail.totalPrice }}</td>
            </tr>
          {% endfor %}

          {% if orderPreview.productDetails|length > productsPreviewLimit %}
            <tr>
              <td colspan="6">
                <a href="#" class="js-preview-more-products-btn text-dark">
                  <i class="material-icons">more_horiz</i>
                  {{ '(%count% more)'|trans({
                    '%count%': orderPreview.productDetails|length - productsPreviewLimit
                  }, 'Admin.Global') }}
                </a>
              </td>
            </tr>
          {% endif %}
          </tbody>
        </table>
      </div>

      <div class="text-right">
        <a href="{{ path('admin_orders_view', {'orderId': orderId}) }}" class="btn btn-primary btn-sm mb-3">
          {{ 'Open details'|trans({}, 'Admin.Orderscustomers.Feature') }}
          <i class="material-icons">arrow_right_alt</i>
        </a>
      </div>
    </div>
  </div>
  {{ renderhook('displayOrderPreview', {'order_id': orderId}) }}
{% endblock %}

